package io.renren.modules.admin.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.admin.entity.CadesStyleEntity;
import io.renren.modules.admin.service.CadesStyleService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 学员风采
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-12-17 18:24:00
 */
@RestController
@RequestMapping("admin/cadesstyle")
public class CadesStyleController {
    @Autowired
    private CadesStyleService cadesStyleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("admin:cadesstyle:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cadesStyleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{cadetStyleId}")
    @RequiresPermissions("admin:cadesstyle:info")
    public R info(@PathVariable("cadetStyleId") Long cadetStyleId){
		CadesStyleEntity cadesStyle = cadesStyleService.getById(cadetStyleId);

        return R.ok().put("cadesStyle", cadesStyle);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("admin:cadesstyle:save")
    public R save(@RequestBody CadesStyleEntity cadesStyle){
		cadesStyleService.save(cadesStyle);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("admin:cadesstyle:update")
    public R update(@RequestBody CadesStyleEntity cadesStyle){
		cadesStyleService.updateById(cadesStyle);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("admin:cadesstyle:delete")
    public R delete(@RequestBody Long[] cadetStyleIds){
		cadesStyleService.removeByIds(Arrays.asList(cadetStyleIds));

        return R.ok();
    }

}
